<html>
<head><meta charset="utf-8"><title>issue-52739 · t-compiler/wg-nll · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/index.html">t-compiler/wg-nll</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-52739.html">issue-52739</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="130355473"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-52739/near/130355473" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-52739.html#130355473">(Jul 26 2018 at 16:20)</a>:</h4>
<p>I assume for <a href="https://github.com/rust-lang/rust/issues/52739" target="_blank" title="https://github.com/rust-lang/rust/issues/52739">#52739</a> (the example from the in-band-lifetimes topic) that this is experimenting with disabling some of the nice region errors?</p>



<a name="130355492"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-52739/near/130355492" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-52739.html#130355492">(Jul 26 2018 at 16:21)</a>:</h4>
<p>cc <span class="user-mention" data-user-id="116009">@nikomatsakis</span></p>



<a name="130355510"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-52739/near/130355510" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-52739.html#130355510">(Jul 26 2018 at 16:21)</a>:</h4>
<p>I also filed <a href="https://github.com/rust-lang/rust/issues/52742" target="_blank" title="https://github.com/rust-lang/rust/issues/52742">https://github.com/rust-lang/rust/issues/52742</a></p>



<a name="130355518"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-52739/near/130355518" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-52739.html#130355518">(Jul 26 2018 at 16:21)</a>:</h4>
<p><span class="user-mention" data-user-id="116107">@David Wood</span> I think we should just disable the "nice region errors" altogether in NLL, at least as an experiment</p>



<a name="130355519"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-52739/near/130355519" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-52739.html#130355519">(Jul 26 2018 at 16:22)</a>:</h4>
<p>I'd be curious to see the impact</p>



<a name="130355520"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-52739/near/130355520" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-52739.html#130355520">(Jul 26 2018 at 16:22)</a>:</h4>
<p>Sure thing.</p>



<a name="130355572"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-52739/near/130355572" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-52739.html#130355572">(Jul 26 2018 at 16:22)</a>:</h4>
<p>Should I self-assign that issue too?</p>



<a name="130355573"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-52739/near/130355573" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-52739.html#130355573">(Jul 26 2018 at 16:22)</a>:</h4>
<p>in particular, I think that maybe you can make a case that the <code>'1</code> errors are better even in cases where the nice region errors work perfectly -- the reason being consistency</p>



<a name="130355576"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-52739/near/130355576" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-52739.html#130355576">(Jul 26 2018 at 16:22)</a>:</h4>
<p>sounds good</p>



<a name="130355579"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-52739/near/130355579" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-52739.html#130355579">(Jul 26 2018 at 16:22)</a>:</h4>
<p>(but I'm not sure about)</p>



<a name="130355617"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-52739/near/130355617" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-52739.html#130355617">(Jul 26 2018 at 16:23)</a>:</h4>
<p>I could imagine us wanting to port some of the "nice regon error" logic over to NLL in more restricted form</p>



<a name="130355623"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-52739/near/130355623" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-52739.html#130355623">(Jul 26 2018 at 16:23)</a>:</h4>
<p>but first step is to turn them off and see the effects</p>



<a name="130413556"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-52739/near/130413556" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-52739.html#130413556">(Jul 27 2018 at 14:24)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> <span class="user-mention" data-user-id="116122">@simulacrum</span> here's the output from running all the UI tests without "nice region errors": <a href="https://gist.github.com/davidtwco/49400ddc324fcdd809eaed7886d153a7" target="_blank" title="https://gist.github.com/davidtwco/49400ddc324fcdd809eaed7886d153a7">https://gist.github.com/davidtwco/49400ddc324fcdd809eaed7886d153a7</a></p>
<p>There are certainly some cases where it's a straight improvement:</p>
<div class="codehilite"><pre><span></span>-   error[E0621]: explicit lifetime required in the type of `x`
+   error: unsatisfied lifetime constraints
8     --&gt; $DIR/impl-trait-captures.rs:21:5
9      |
10  LL | fn foo&lt;&#39;a, T&gt;(x: &amp;T) -&gt; impl Foo&lt;&#39;a&gt; {

-      |               - consider changing the type of `x` to `&amp;ReEarlyBound(0, &#39;a) T`
+      |                  - let&#39;s call the lifetime of this reference `&#39;1`
12  LL |     x
-      |     ^ lifetime `ReEarlyBound(0, &#39;a)` required
+      |     ^ return requires that `&#39;1` must outlive `&#39;a`
14
15  error: aborting due to previous error
16

-   For more information about this error, try `rustc --explain E0621`.
18
</pre></div>


<p>But there are others where I'm not sure. We can take a look and work out whether some of the nice region errors are worth keeping - I'm not great at deciding what is or isn't a good diagnostic.</p>



<a name="130414485"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-52739/near/130414485" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-52739.html#130414485">(Jul 27 2018 at 14:41)</a>:</h4>
<p>I like the <em>concept</em> of "let's call the lifetime of this reference <code>'1</code>"; wonder if there's a slightly less informal phrasing...</p>



<a name="130414545"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-52739/near/130414545" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-52739.html#130414545">(Jul 27 2018 at 14:42)</a>:</h4>
<p>Removing <code>ReEarlyBound</code> is a strong improvement ;-)</p>



<a name="130434027"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-52739/near/130434027" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-52739.html#130434027">(Jul 27 2018 at 20:30)</a>:</h4>
<p>Wrote up some thoughts I have on the three different types of nice region error (as far as I can tell, that's how many there are) in this document:<br>
<a href="https://paper.dropbox.com/doc/NLL-Nice-Region-Errors--AItgZNRfVxL1lME1ynRELQyAAQ-Ci1DqrXWuM1mVO0CMGkCS" target="_blank" title="https://paper.dropbox.com/doc/NLL-Nice-Region-Errors--AItgZNRfVxL1lME1ynRELQyAAQ-Ci1DqrXWuM1mVO0CMGkCS">https://paper.dropbox.com/doc/NLL-Nice-Region-Errors--AItgZNRfVxL1lME1ynRELQyAAQ-Ci1DqrXWuM1mVO0CMGkCS</a></p>



<a name="130449598"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-52739/near/130449598" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-52739.html#130449598">(Jul 28 2018 at 04:00)</a>:</h4>
<p><span class="user-mention" data-user-id="116107">@David Wood</span> that one you quoted isn't a real test, because it includes <code>-Z verbose</code> in the compile-flags, which is why we print the <code>ReEarlyBound</code></p>



<a name="130449599"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-52739/near/130449599" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-52739.html#130449599">(Jul 28 2018 at 04:00)</a>:</h4>
<p>iirc</p>



<a name="130449650"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-52739/near/130449650" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-52739.html#130449650">(Jul 28 2018 at 04:02)</a>:</h4>
<p>I'll skim the results; I think that the nice-error-messages (and to a lesser extent our new ones) also suffer from the problem sometimes of not giving you enough info. In particular, I've gotten suggests like "consider changing the type of <code>tcx</code> to <code>TyCtxt&lt;'tcx, 'tcx, 'tcx&gt;</code> -- which I <em>know</em> is wrong, and I wish it would just tell me <em>why</em> it thinks I should do that</p>



<a name="130457100"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-52739/near/130457100" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-52739.html#130457100">(Jul 28 2018 at 08:38)</a>:</h4>
<p>Ah, should've noticed that.</p>



<a name="130466963"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-52739/near/130466963" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-52739.html#130466963">(Jul 28 2018 at 13:12)</a>:</h4>
<p>this is an interesting one</p>
<div class="codehilite"><pre><span></span>4   LL |     &amp;*x
5      |     ^^^
6
<span class="gd">-   error[E0623]: lifetime mismatch</span>
<span class="gi">+   error: unsatisfied lifetime constraints</span>
8     --&gt; $DIR/region-lbr1-does-not-outlive-ebr2.rs:19:5
9      |
<span class="gd">-   LL | fn foo&lt;&#39;a, &#39;b&gt;(x: &amp;&#39;a u32, y: &amp;&#39;b u32) -&gt; &amp;&#39;b u32 {</span>
<span class="gd">-      |                   -------                 -------</span>
<span class="gd">-      |                   |</span>
<span class="gd">-      |                   this parameter and the return type are declared with different lifetimes...</span>
14  LL |     &amp;*x
<span class="gd">-      |     ^^^ ...but data from `x` is returned here</span>
<span class="gi">+      |     ^^^ requires that `&#39;a` must outlive `&#39;b`</span>
16
17  error: aborting due to previous error
18

<span class="gd">-   For more information about this error, try `rustc --explain E0623`.</span>
20
</pre></div>



<a name="130466975"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-52739/near/130466975" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-52739.html#130466975">(Jul 28 2018 at 13:12)</a>:</h4>
<p>that is the specific message where I think -- in general -- the new-style messages are superior, as they give more info</p>



<a name="130466980"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-52739/near/130466980" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-52739.html#130466980">(Jul 28 2018 at 13:13)</a>:</h4>
<p>though I think maybe a "medley" would be even better</p>



<a name="130467043"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-52739/near/130467043" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-52739.html#130467043">(Jul 28 2018 at 13:14)</a>:</h4>
<p>e.g.</p>
<div class="codehilite"><pre><span></span>-   error[E0623]: lifetime mismatch
8     --&gt; $DIR/region-lbr1-does-not-outlive-ebr2.rs:19:5
9      |
    LL | fn foo&lt;&#39;a, &#39;b&gt;(x: &amp;&#39;a u32, y: &amp;&#39;b u32) -&gt; &amp;&#39;b u32 {
       |                   -                       -
       |                   |
       |                   these two references have different lifetimes
14  LL |     &amp;*x
       |     ^^^ ...but data from `x` is returned here
16
17  error: aborting due to previous error
18
</pre></div>



<a name="130467056"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-52739/near/130467056" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-52739.html#130467056">(Jul 28 2018 at 13:14)</a>:</h4>
<p>er, I don't know, in this case it doesn't matter so much. I am more thinking of cases though where the type is more complex</p>



<a name="130467070"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-52739/near/130467070" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-52739.html#130467070">(Jul 28 2018 at 13:15)</a>:</h4>
<p>alternatively, in the new style message, it might be nice if we would highlight the <code>'a</code> in the reference</p>



<a name="130467075"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-52739/near/130467075" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-52739.html#130467075">(Jul 28 2018 at 13:15)</a>:</h4>
<p>even though we have a proper name to use</p>



<a name="130470118"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-52739/near/130470118" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-52739.html#130470118">(Jul 28 2018 at 14:28)</a>:</h4>
<p>Yeah, for that example, new errors would be better if they highlighted the arguments like the nice region errors do.</p>



<a name="130572188"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-52739/near/130572188" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-52739.html#130572188">(Jul 30 2018 at 11:37)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> what would you like me to do for this issue (and <a href="https://github.com/rust-lang/rust/issues/52742" target="_blank" title="https://github.com/rust-lang/rust/issues/52742">#52742</a>)? - I've got time this week to work on a PR but not sure how we want to address this issue.</p>



<a name="130578814"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-52739/near/130578814" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-52739.html#130578814">(Jul 30 2018 at 13:27)</a>:</h4>
<p><span class="user-mention" data-user-id="116107">@David Wood</span> I don't know exactly either. I was considering trying to re-implement the nice-region-errors but adjust them? I guess we have to study that gist of yours with the diff from turning them off and decide what to keep and what not</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>